<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - poll/unix/pollcb.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">poll/unix</a> - pollcb.c<span style="font-size: 80%;"> (source / <a href="pollcb.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">42</td>
            <td class="headerCovTableEntry">47</td>
            <td class="headerCovTableEntryMed">89.4 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">5</td>
            <td class="headerCovTableEntry">5</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">19</td>
            <td class="headerCovTableEntry">26</td>
            <td class="headerCovTableEntryLo">73.1 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #ifdef WIN32
<span class="lineNum">      18 </span>                :            : /* POSIX defines 1024 for the FD_SETSIZE */
<span class="lineNum">      19 </span>                :            : #define FD_SETSIZE 1024
<span class="lineNum">      20 </span>                :            : #endif
<span class="lineNum">      21 </span>                :            : 
<span class="lineNum">      22 </span>                :            : #include &quot;apr.h&quot;
<span class="lineNum">      23 </span>                :            : #include &quot;apr_poll.h&quot;
<span class="lineNum">      24 </span>                :            : #include &quot;apr_time.h&quot;
<span class="lineNum">      25 </span>                :            : #include &quot;apr_portable.h&quot;
<span class="lineNum">      26 </span>                :            : #include &quot;apr_arch_file_io.h&quot;
<span class="lineNum">      27 </span>                :            : #include &quot;apr_arch_networkio.h&quot;
<span class="lineNum">      28 </span>                :            : #include &quot;apr_arch_poll_private.h&quot;
<span class="lineNum">      29 </span>                :            : 
<span class="lineNum">      30 </span>                :            : static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD;
<span class="lineNum">      31 </span>                :            : #if defined(HAVE_KQUEUE)
<span class="lineNum">      32 </span>                :            : extern apr_pollcb_provider_t *apr_pollcb_provider_kqueue;
<span class="lineNum">      33 </span>                :            : #endif
<span class="lineNum">      34 </span>                :            : #if defined(HAVE_PORT_CREATE)
<span class="lineNum">      35 </span>                :            : extern apr_pollcb_provider_t *apr_pollcb_provider_port;
<span class="lineNum">      36 </span>                :            : #endif
<span class="lineNum">      37 </span>                :            : #if defined(HAVE_EPOLL)
<span class="lineNum">      38 </span>                :            : extern apr_pollcb_provider_t *apr_pollcb_provider_epoll;
<span class="lineNum">      39 </span>                :            : #endif
<span class="lineNum">      40 </span>                :            : #if defined(HAVE_POLL)
<span class="lineNum">      41 </span>                :            : extern apr_pollcb_provider_t *apr_pollcb_provider_poll;
<span class="lineNum">      42 </span>                :            : #endif
<span class="lineNum">      43 </span>                :            : 
<a name="44"><span class="lineNum">      44 </span>                :            : static apr_pollcb_provider_t *pollcb_provider(apr_pollset_method_e method)</a>
<span class="lineNum">      45 </span>                :            : {
<span class="lineNum">      46 </span>                :<span class="lineCov">          9 :     apr_pollcb_provider_t *provider = NULL;</span>
<span class="lineNum">      47 </span>     [<span class="branchCov" title="Branch 0 was taken 3 times"> + </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span><span class="branchCov" title="Branch 2 was taken 4 times"> + </span>]:<span class="lineCov">          9 :     switch (method) {</span>
<span class="lineNum">         </span>     [<span class="branchCov" title="Branch 3 was taken 1 time"> + </span><span class="branchNoCov" title="Branch 4 was not taken"> - </span><span class="branchNoCov" title="Branch 5 was not taken"> - </span>]
<span class="lineNum">      48 </span>                :            :         case APR_POLLSET_KQUEUE:
<span class="lineNum">      49 </span>                :            : #if defined(HAVE_KQUEUE)
<span class="lineNum">      50 </span>                :            :             provider = apr_pollcb_provider_kqueue;
<span class="lineNum">      51 </span>                :            : #endif
<span class="lineNum">      52 </span>                :            :         break;
<span class="lineNum">      53 </span>                :            :         case APR_POLLSET_PORT:
<span class="lineNum">      54 </span>                :            : #if defined(HAVE_PORT_CREATE)
<span class="lineNum">      55 </span>                :            :             provider = apr_pollcb_provider_port;
<span class="lineNum">      56 </span>                :            : #endif
<span class="lineNum">      57 </span>                :            :         break;
<span class="lineNum">      58 </span>                :            :         case APR_POLLSET_EPOLL:
<span class="lineNum">      59 </span>                :            : #if defined(HAVE_EPOLL)
<span class="lineNum">      60 </span>                :<span class="lineCov">          4 :             provider = apr_pollcb_provider_epoll;</span>
<span class="lineNum">      61 </span>                :            : #endif
<span class="lineNum">      62 </span>                :            :         break;
<span class="lineNum">      63 </span>                :            :         case APR_POLLSET_POLL:
<span class="lineNum">      64 </span>                :            : #if defined(HAVE_POLL)
<span class="lineNum">      65 </span>                :<span class="lineCov">          1 :             provider = apr_pollcb_provider_poll;</span>
<span class="lineNum">      66 </span>                :            : #endif
<span class="lineNum">      67 </span>                :            :         break;
<span class="lineNum">      68 </span>                :            :         case APR_POLLSET_SELECT:
<span class="lineNum">      69 </span>                :            :         case APR_POLLSET_DEFAULT:
<span class="lineNum">      70 </span>                :            :         break;
<span class="lineNum">      71 </span>                :            :     }
<span class="lineNum">      72 </span>                :<span class="lineCov">          9 :     return provider;</span>
<span class="lineNum">      73 </span>                :            : }
<span class="lineNum">      74 </span>                :            : 
<span class="lineNum">      75 </span>                :            : APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb,
<span class="lineNum">      76 </span>                :            :                                                apr_uint32_t size,
<span class="lineNum">      77 </span>                :            :                                                apr_pool_t *p,
<span class="lineNum">      78 </span>                :            :                                                apr_uint32_t flags,
<span class="lineNum">      79 </span>                :            :                                                apr_pollset_method_e method)
<span class="lineNum">      80 </span>                :<span class="lineCov">          6 : {</span>
<span class="lineNum">      81 </span>                :            :     apr_status_t rv;
<span class="lineNum">      82 </span>                :            :     apr_pollcb_t *pollcb;
<span class="lineNum">      83 </span>                :<span class="lineCov">          6 :     apr_pollcb_provider_t *provider = NULL;</span>
<span class="lineNum">      84 </span>                :            : 
<span class="lineNum">      85 </span>                :<span class="lineCov">          6 :     *ret_pollcb = NULL;</span>
<span class="lineNum">      86 </span>                :            : 
<span class="lineNum">      87 </span>                :            :  #ifdef WIN32
<span class="lineNum">      88 </span>                :            :     /* This will work only if ws2_32.dll has WSAPoll funtion.
<span class="lineNum">      89 </span>                :            :      * We could check the presence of the function here,
<span class="lineNum">      90 </span>                :            :      * but someone might implement other pollcb method in
<span class="lineNum">      91 </span>                :            :      * the future.
<span class="lineNum">      92 </span>                :            :      */
<span class="lineNum">      93 </span>                :            :     if (method == APR_POLLSET_DEFAULT) {
<span class="lineNum">      94 </span>                :            :         method = APR_POLLSET_POLL;
<span class="lineNum">      95 </span>                :            :     }
<span class="lineNum">      96 </span>                :            :  #endif
<span class="lineNum">      97 </span>                :            : 
<span class="lineNum">      98 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 5 times"> + </span>]:<span class="lineCov">          6 :     if (method == APR_POLLSET_DEFAULT)</span>
<span class="lineNum">      99 </span>                :<span class="lineCov">          1 :         method = pollset_default_method;</span>
<span class="lineNum">     100 </span>        [<span class="branchCov" title="Branch 0 was taken 8 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">         12 :     while (provider == NULL) {</span>
<span class="lineNum">     101 </span>                :<span class="lineCov">          8 :         provider = pollcb_provider(method);</span>
<span class="lineNum">     102 </span>        [<span class="branchCov" title="Branch 0 was taken 4 times"> + </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          8 :         if (!provider) {</span>
<span class="lineNum">     103 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :             if ((flags &amp; APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT)</span>
<span class="lineNum">     104 </span>                :<span class="lineCov">          2 :                 return APR_ENOTIMPL;</span>
<span class="lineNum">     105 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :             if (method == pollset_default_method)</span>
<span class="lineNum">     106 </span>                :<span class="lineNoCov">          0 :                 return APR_ENOTIMPL;</span>
<span class="lineNum">     107 </span>                :<span class="lineCov">          2 :             method = pollset_default_method;</span>
<span class="lineNum">     108 </span>                :            :         }
<span class="lineNum">     109 </span>                :            :     }
<span class="lineNum">     110 </span>                :            : 
<span class="lineNum">     111 </span>                :<span class="lineCov">          4 :     pollcb = apr_palloc(p, sizeof(*pollcb));</span>
<span class="lineNum">     112 </span>                :<span class="lineCov">          4 :     pollcb-&gt;nelts = 0;</span>
<span class="lineNum">     113 </span>                :<span class="lineCov">          4 :     pollcb-&gt;nalloc = size;</span>
<span class="lineNum">     114 </span>                :<span class="lineCov">          4 :     pollcb-&gt;pool = p;</span>
<span class="lineNum">     115 </span>                :<span class="lineCov">          4 :     pollcb-&gt;provider = provider;</span>
<span class="lineNum">     116 </span>                :            : 
<span class="lineNum">     117 </span>                :<span class="lineCov">          4 :     rv = (*provider-&gt;create)(pollcb, size, p, flags);</span>
<span class="lineNum">     118 </span>        [<span class="branchCov" title="Branch 0 was taken 1 time"> + </span><span class="branchCov" title="Branch 1 was taken 3 times"> + </span>]:<span class="lineCov">          4 :     if (rv == APR_ENOTIMPL) {</span>
<span class="lineNum">     119 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :         if (method == pollset_default_method) {</span>
<span class="lineNum">     120 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     121 </span>                :            :         }
<span class="lineNum">     122 </span>                :            : 
<span class="lineNum">     123 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :         if ((flags &amp; APR_POLLSET_NODEFAULT) == APR_POLLSET_NODEFAULT) {</span>
<span class="lineNum">     124 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     125 </span>                :            :         }
<span class="lineNum">     126 </span>                :            : 
<span class="lineNum">     127 </span>                :            :         /* Try with default provider */
<span class="lineNum">     128 </span>                :<span class="lineCov">          2 :         provider = pollcb_provider(pollset_default_method);</span>
<span class="lineNum">     129 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :         if (!provider) {</span>
<span class="lineNum">     130 </span>                :<span class="lineNoCov">          0 :             return APR_ENOTIMPL;</span>
<span class="lineNum">     131 </span>                :            :         }
<span class="lineNum">     132 </span>                :<span class="lineCov">          1 :         rv = (*provider-&gt;create)(pollcb, size, p, flags);</span>
<span class="lineNum">     133 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 1 time"> + </span>]:<span class="lineCov">          1 :         if (rv != APR_SUCCESS) {</span>
<span class="lineNum">     134 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">     135 </span>                :            :         }
<span class="lineNum">     136 </span>                :<span class="lineCov">          1 :         pollcb-&gt;provider = provider;</span>
<span class="lineNum">     137 </span>                :            :     }
<span class="lineNum">     138 </span>                :            : 
<span class="lineNum">     139 </span>                :<span class="lineCov">          4 :     *ret_pollcb = pollcb;</span>
<span class="lineNum">     140 </span>                :<span class="lineCov">          6 :     return APR_SUCCESS;</span>
<span class="lineNum">     141 </span>                :            : }
<span class="lineNum">     142 </span>                :            : 
<span class="lineNum">     143 </span>                :            : APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb,
<span class="lineNum">     144 </span>                :            :                                             apr_uint32_t size,
<a name="145"><span class="lineNum">     145 </span>                :            :                                             apr_pool_t *p,</a>
<span class="lineNum">     146 </span>                :            :                                             apr_uint32_t flags)
<span class="lineNum">     147 </span>                :<span class="lineCov">          1 : {</span>
<span class="lineNum">     148 </span>                :<span class="lineCov">          1 :     apr_pollset_method_e method = APR_POLLSET_DEFAULT;</span>
<span class="lineNum">     149 </span>                :<span class="lineCov">          1 :     return apr_pollcb_create_ex(pollcb, size, p, flags, method);</span>
<span class="lineNum">     150 </span>                :            : }
<span class="lineNum">     151 </span>                :            : 
<a name="152"><span class="lineNum">     152 </span>                :            : APR_DECLARE(apr_status_t) apr_pollcb_add(apr_pollcb_t *pollcb,</a>
<span class="lineNum">     153 </span>                :            :                                          apr_pollfd_t *descriptor)
<span class="lineNum">     154 </span>                :<span class="lineCov">          2 : {</span>
<span class="lineNum">     155 </span>                :<span class="lineCov">          2 :     return (*pollcb-&gt;provider-&gt;add)(pollcb, descriptor);</span>
<span class="lineNum">     156 </span>                :            : }
<span class="lineNum">     157 </span>                :            : 
<a name="158"><span class="lineNum">     158 </span>                :            : APR_DECLARE(apr_status_t) apr_pollcb_remove(apr_pollcb_t *pollcb,</a>
<span class="lineNum">     159 </span>                :            :                                             apr_pollfd_t *descriptor)
<span class="lineNum">     160 </span>                :<span class="lineCov">          2 : {</span>
<span class="lineNum">     161 </span>                :<span class="lineCov">          2 :     return (*pollcb-&gt;provider-&gt;remove)(pollcb, descriptor);</span>
<span class="lineNum">     162 </span>                :            : }
<span class="lineNum">     163 </span>                :            : 
<span class="lineNum">     164 </span>                :            : 
<span class="lineNum">     165 </span>                :            : APR_DECLARE(apr_status_t) apr_pollcb_poll(apr_pollcb_t *pollcb,
<span class="lineNum">     166 </span>                :            :                                           apr_interval_time_t timeout,
<a name="167"><span class="lineNum">     167 </span>                :            :                                           apr_pollcb_cb_t func,</a>
<span class="lineNum">     168 </span>                :            :                                           void *baton)
<span class="lineNum">     169 </span>                :<span class="lineCov">          3 : {</span>
<span class="lineNum">     170 </span>                :<span class="lineCov">          3 :     return (*pollcb-&gt;provider-&gt;poll)(pollcb, timeout, func, baton);</span>
<span class="lineNum">     171 </span>                :            : }
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
